<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	Mar 21, 2012
 ^
 + Project: 		WRecruit
 * File Name:	views/jobseeker/tmpl/filters.php
 ^ 
 * Description: template view for filters
 ^ 
 * History:		NONE
 ^ 
 */
 
 defined('_JEXEC') or die('Restricted access');
  $document =& JFactory::getDocument();
   $document->addStyleSheet('components/com_wrecruit/css/'.$this->config['theme']);

 global $mainframe;

jimport('joomla.filter.output');
$filter_address_fields_width = $this->config['filter_address_fields_width'];
?>

<?php if ($this->config['filter'] == 1) { ?>
		<table cellpadding="0" cellspacing="0" border="0" width="100%" class="tbfilters">
		<tr><td>
			<table cellpadding="0" cellspacing="0" border="0" width="100%" >
				<tr><td colspan="6" height="10"></td></tr>
				<?php if ($this->config['filter_address'] == 1) { ?>
					<tr>            <?php $style = "width:".$this->config['filter_address_fields_width']."px;"; ?>
								<td width="2"></td>
								<?php if($this->config['hidecountry'] != 1){ ?>

                                                        <!-- scs -->        <?php if ($this->config['filter_address_country'] == 1) {  ?> <!-- sce -->
                                                                                          <td id="filter_country" width="25%">
                                                                                          <?php echo $this->filterlists['country']; ?>
                                                                            </td>
                                                             <!-- scs -->   <?php } ?> <!-- sce -->
								<?php } ?>								


                                         <!-- scs -->           <?php if ($this->config['filter_address_state'] == 1) {  ?> <!-- sce -->

                                                                            <td id="filter_state" width="40">
								<?php
                                                                            if ((isset($this->filterlists['state'])) && ($this->filterlists['state']!='')){
                                                                                    echo $this->filterlists['state'];
                                                                            } else{
                                                                            if(isset($this->filtervalues)) if($this->filtervalues['state'] != '') $statevalue = $this->filtervalues['state']; else { $statevalue = 'State'; $style .= 'color:#808080;';} else { $statevalue = 'State'; $style .= 'color:#808080;';}
                                                                            ?>
										<input class="inputbox" type="text" name="txtfilter_state" style="<?php echo $style; ?>" size="25" maxlength="50" value="<?php echo $statevalue; ?>"  onfocus="if(this.value == 'State') { this.value = ''; this.style.color='black';}" onblur="if(this.value == '') { this.style.color='#808080';this.value='State';  }"  />
									<?php } ?>
                                                                            </td>
					<!-- scs -->    	<?php } ?> <!-- sce -->

                                        <!-- scs -->            <?php if ($this->config['filter_address_county'] == 1 ) {  ?> <!-- sce -->

                                                                            <td id="filter_county" width="40"><?php
                                                                            if ((isset($this->filterlists['county'])) && ($this->filterlists['county']!='')){
                                                                                    echo $this->filterlists['county'];
                                                                            } else{
                                                                                if(isset($this->filtervalues)) if($this->filtervalues['county'] != '') $countyvalue = $this->filtervalues['county']; else { $countyvalue = 'County'; $style .= 'color:#808080;';} else { $countyvalue = 'County'; $style .= 'color:#808080;';}
                                                                                ?>
                                                                                    <input class="inputbox" type="text" name="txtfilter_county" style="<?php echo $style ?>" size="25" maxlength="50" value="<?php echo $countyvalue; ?>" onfocus="if(this.value == 'County') { this.value = ''; this.style.color='black';}" onblur="if(this.value == '') { this.style.color='#808080';this.value='County';  }"/>
                                                                            <?php } ?>
                                                                            </td>
					<!-- scs --> 			<?php } ?><!-- sce -->




                                     <!-- scs -->               <?php if ($this->config['filter_address_city'] == 1 ) {  ?> <!-- sce -->


                                                                            <td id="filter_city" width="40"><?php
                                                                            if((isset($this->filterlists['city'])) && ($this->filterlists['city']!='')){
                                                                                    echo $this->filterlists['city'];
                                                                            } else{
                                                                                if(isset($this->filtervalues)) if($this->filtervalues['city'] != '') $cityvalue = $this->filtervalues['city']; else { $cityvalue = 'City'; $style .= 'color:#808080;';} else { $cityvalue = 'City'; $style .= 'color:#808080;';}
                                                                                ?>
                                                                                    <input class="inputbox" type="text" name="txtfilter_city" style="<?php echo $style; ?>" size="25" maxlength="50" value="<?php echo $cityvalue; ?>" onfocus="if(this.value == 'City') { this.value = ''; this.style.color='black';}" onblur="if(this.value == '') { this.style.color='#808080';this.value='City';  }"/>
                                                                            <?php } ?>
                                                                            </td>
					<!-- scs --> 		<?php } ?>    

								<?php if($this->config['filter_address_country'] != 1) echo "<td></td>" ; ?>
								<?php if($this->config['filter_address_state'] != 1) echo "<td></td>" ; ?>
								<?php if($this->config['filter_address_county'] != 1) echo "<td></td>" ; ?>
								<?php if($this->config['filter_address_city'] != 1) echo "<td></td>" ; ?>
                                        <!-- sce -->

								<?php if($this->config['hidecountry'] != 1) echo "<td></td>" ; ?>
								
                                                                            <td width="2"></td>
						
					</tr>
					<tr><td colspan="6" height="2"></td></tr>
				<?php } ?>
				<tr>
					<td ></td>
					<td> <?php if ($this->config['filter_category'] == 1)  echo $this->filterlists['jobcategory']; ?></td>
					<td> <?php if ($this->config['filter_jobtype'] == 1) echo $this->filterlists['jobtype']; ?></td>
					<td  align="left">
						<?php 
							if(isset($this->userrole)){
								if (isset($this->uid) && (isset($this->userrole->rolefor))){ ?>
								<?php if (isset($this->filterid)) { ?>
									<button class="button" onclick="deleteSearch();"><?php echo JText::_( 'JS_THIS_FILTER_DELETE' ); ?></button>
								<?php } else { ?>
									<button class="button" onclick="saveSearch();"><?php echo JText::_( 'JS_THIS_FILTER_SAVE' ); ?></button>
								<?php } ?>
							<?php } 
							} ?>
					</td>
					<td  align="left" nowrap>
						<button class="button" onclick="this.form.submit();"><?php echo JText::_( 'JS_GO' ); ?></button>
						&nbsp;<button class="button" onclick="myReset();"><?php echo JText::_( 'JS_RESET' ); ?></button>
					</td>
					<td ></td>
				<tr>
				<tr><td colspan="6" height="4"></td></tr>
			</table>
		</td></tr>
		</table>	
		<input type="hidden" name="id" value="<?php echo $this->filterid; ?>">
		<input type="hidden" name="formaction" value="">
		

<script language=Javascript>
function saveSearch(){
	document.adminForm.formaction.value = document.adminForm.action;
// alert(document.adminForm.action);
	document.adminForm.action = 'index.php?option=com_wrecruit&c=wrecruit&task=savefilter';
 document.adminForm.submit();
 
 }

function deleteSearch(){
	document.adminForm.formaction.value = document.adminForm.action;
// alert(document.adminForm.action);
	document.adminForm.action = 'index.php?option=com_wrecruit&c=wrecruit&task=deletefilter';
 document.adminForm.submit();
 }
function myReset(){
// alert('reset');
if (testIsValidObject(document.adminForm.cmbfilter_country)) document.adminForm.cmbfilter_country.value = '';
if (testIsValidObject(document.adminForm.cmbfilter_state)) document.adminForm.cmbfilter_state.value = '';
if (testIsValidObject(document.adminForm.cmbfilter_county)) document.adminForm.cmbfilter_county.value = '';
if (testIsValidObject(document.adminForm.cmbfilter_city)) document.adminForm.cmbfilter_city.value = '';
if (testIsValidObject(document.adminForm.txtfilter_country)) document.adminForm.txtfilter_country.value = '';
if (testIsValidObject(document.adminForm.txtfilter_state)) document.adminForm.txtfilter_state.value = '';
if (testIsValidObject(document.adminForm.txtfilter_county)) document.adminForm.txtfilter_county.value = '';
if (testIsValidObject(document.adminForm.txtfilter_city)) document.adminForm.txtfilter_city.value = '';
 
 document.adminForm.filter_jobcategory.value = '';
 document.adminForm.filter_jobtype.value = '';
// document.adminForm.filter_jobsalaryrange.value = '';
 //document.adminForm.filter_heighesteducation.value = '';
 document.adminForm.submit();
//alert('reset 2');
 
 }

function testIsValidObject(objToTest) {
		if (null == objToTest) {
			return false;
		}
		if ("undefined" == typeof(objToTest) ) {
			return false;
		}
		return true;

}

//function dochange(curscr, myname, nextname, src, val){
function filter_dochange(src, val){
	document.getElementById(src).innerHTML="Loading ...";
	var xhr; 
	<?php echo 'var field_width = '.$filter_address_fields_width; ?>

	try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
	catch (e) 
	{
		try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
		catch (e2) 
		{
		  try {  xhr = new XMLHttpRequest();     }
		  catch (e3) {  xhr = false;   }
		}
	 }

	xhr.onreadystatechange = function(){
      if(xhr.readyState == 4 && xhr.status == 200){
        	document.getElementById(src).innerHTML=xhr.responseText; //retuen value

			if(src =='filter_state'){
				countyhtml = "<input class='inputbox' type='text' name='txtfilter_county' style='width:"+field_width+"px;color:#808080;'  size='25' maxlength='50' value='County' onfocus='if(this.value == \"County\"){this.value = \"\";this.style.color=\"black\";};' onblur='if(this.value == \"\") { this.style.color=\"#808080\";this.value=\"County\";  }' />";
				cityhtml = "<input class='inputbox' type='text' name='txtfilter_city' style='width:"+field_width+"px;color:#808080;' size='25' maxlength='50' value='City' onfocus='if(this.value == \"City\") { this.value = \"\"; this.style.color=\"black\";}' onblur='if(this.value == \"\") { this.style.color=\"#808080\";this.value=\"City\";  }'/>";
				document.getElementById('filter_county').innerHTML=countyhtml; //retuen value
				document.getElementById('filter_city').innerHTML=cityhtml; //retuen value
			}else if(src =='filter_county'){
				cityhtml = "<input class='inputbox' type='text' name='txtfilter_city' style='width:"+field_width+"px;color:#808080;' size='25' maxlength='50' value='City' onfocus='if(this.value == \"City\") { this.value = \"\"; this.style.color=\"black\";}' onblur='if(this.value == \"\") { this.style.color=\"#808080\";this.value=\"City\";  }'/>";
				document.getElementById('filter_city').innerHTML=cityhtml; //retuen value
			}
      }
    }
 
//	xhr.open("GET","index.php?option=com_wrecruit&task=listempaddressdata&name="+curscr+"&myname="+myname+"&nextname="+nextname+"&data="+src+"&val="+val,true);
	xhr.open("GET","index.php?option=com_wrecruit&task=listfilteraddressdata&data="+src+"&val="+val,true);
	xhr.send(null);
}

//window.onLoad=dochange('country', -1);         // value in first dropdown
</script>

<?php } ?>
